Skip to content

Embeds: Fix get_site_icon_url() dropping fallback when attachment URL…#11601

Open
Sukhendu2002 wants to merge 14 commits intoWordPress:trunkfrom
Sukhendu2002:fix/65098-get-site-icon-url-fallback
Open

Embeds: Fix get_site_icon_url() dropping fallback when attachment URL…#11601
Sukhendu2002 wants to merge 14 commits intoWordPress:trunkfrom
Sukhendu2002:fix/65098-get-site-icon-url-fallback

Conversation

@Sukhendu2002
Copy link
Copy Markdown

@Sukhendu2002 Sukhendu2002 commented Apr 20, 2026

Trac ticket: https://core.trac.wordpress.org/ticket/65098

Use of AI Tools

AI assistance: No


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@github-actions
Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Comment thread src/wp-includes/embed.php Outdated
@Sukhendu2002 Sukhendu2002 marked this pull request as ready for review April 20, 2026 07:58
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 20, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props sukhendu2002, westonruter, mukesh27, sabernhardt.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Comment thread src/wp-includes/embed.php Outdated
@westonruter
Copy link
Copy Markdown
Member

Can we add tests for get_site_icon_url() and the_embed_site_title() to cover the new code paths?

I see there are existing tests for get_site_icon_url() in tests/phpunit/tests/general/template.php but I don't see existing coverage for the_embed_site_title().

Comment thread tests/phpunit/tests/general/template.php Outdated
Comment thread tests/phpunit/tests/general/template.php Outdated
Comment thread tests/phpunit/tests/general/template.php Outdated
Comment thread tests/phpunit/tests/general/template.php Outdated
Comment thread tests/phpunit/tests/general/template.php Outdated
@westonruter westonruter requested review from Copilot and removed request for sabernhardt April 24, 2026 00:43
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a regression where get_site_icon_url() could drop a provided fallback URL when the attachment URL lookup fails, and updates embed site-title rendering to avoid emitting broken/empty icon attributes.

Changes:

  • Preserve the caller-provided fallback URL in get_site_icon_url() when wp_get_attachment_image_url() returns false.
  • Refactor the_embed_site_title() to conditionally render the site icon markup and omit srcset when appropriate.
  • Add PHPUnit coverage for the fallback behavior and embed site title icon output edge cases (attachment URL failure, empty URL, identical 1x/2x URLs, no site icon set).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
tests/phpunit/tests/general/template.php Adds tests for get_site_icon_url() fallback retention and the_embed_site_title() icon/srcset behaviors.
src/wp-includes/general-template.php Ensures attachment URL failures don’t overwrite a provided fallback URL in get_site_icon_url().
src/wp-includes/embed.php Adjusts embed site title markup to avoid empty src/broken srcset and to omit the icon when URL is empty.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/wp-includes/embed.php Outdated
Comment thread tests/phpunit/tests/general/template.php Outdated
Comment on lines +904 to +905
$this->assertTrue( $processor->next_tag( 'IMG' ), 'Expected IMG tag.' );
$this->assertSame( $svg_url, $processor->get_attribute( 'src' ), '1x URL should be present in src.' );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->assertTrue( $processor->next_tag( 'IMG' ), 'Expected IMG tag.' );
$this->assertSame( $svg_url, $processor->get_attribute( 'src' ), '1x URL should be present in src.' );
$this->assertTrue( $processor->next_tag( 'IMG' ), 'Expected IMG tag.' );
$this->assertTrue( $processor->has_class( 'wp-embed-site-icon' ), 'Expected IMG to have wp-embed-site-icon class.' );
$this->assertSame( $svg_url, $processor->get_attribute( 'src' ), '1x URL should be present in src.' );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker ☝️

Copy link
Copy Markdown
Member

@mukeshpanchal27 mukeshpanchal27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the iterations. Changes looks good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants